/**
 * 
 */
package com.nwpusp.model.props;

import java.util.ArrayList;

import com.nwpusp.model.Entity;
import com.nwpusp.model.EntityClassifyManager;
import com.nwpusp.model.EntityContainer;
import com.nwpusp.model.TrackManager;
import com.nwpusp.model.characters.GameCharacter;
import com.nwpusp.model.location.Axis;
import com.nwpusp.model.location.Size;

/**
 * @author JustinCao
 *
 */
public class PropManager extends EntityClassifyManager {

	private int seidCnt = 0;
	public PropManager(EntityContainer globalContainer, TrackManager trackMgr) {
		super(globalContainer, trackMgr);
	}

	public boolean add(Entity e) {
		if(e instanceof Prop) {
			return super.add(e);
		}
		return false;
	}
	
	public boolean remove(Entity e) {
		if(e instanceof Prop) {
			return super.remove(e);
		}
		return false;
	}
	
	synchronized private int increaseSeidCnt() {
		return seidCnt++;
	}
// Interface for new Prop {
	public void allocProp(Axis pos) {
		allocProp(pos, new Size(450, 450, 450));
	}
	
	public void allocProp(Axis pos, Size size) {
		appendProp(pos, size, increaseSeidCnt());
	}

	public void appendProp(Axis pos, Size size, int seid) {
		Prop p = new Prop(seid);
		p.setPosition(pos);
		p.setSize(size);
		add(p);
	}
	
	synchronized public Prop getPropBySeid(int seid) {
		for(Entity p : this) {
			if(((Prop)p).getStaticEntityId() == seid) {
				return (Prop)p;
			}
		}
		return null;
	}
	
	public void removeProp(int seid) {
		Prop p = getPropBySeid(seid);
		if(p != null) {
			remove(p);
		}
	}
// } Interface for new Prop
	
	public void Init() {
		seidCnt = 0;
// Test code {
		//for(int i = 0; i < 1; i++) {
		//	allocProp(new Axis(100 * (5 + i), 5 * (i), 0), new Size(100, 20, 100));
		//}
		
		//Prop p2 = new Prop();
		//p2.setPosition(new Axis(100 * 22, 160, 0));
		//p2.setSize(new Size(20, 20, 40));
		//add(p2);
// } Test code
	}
}
